package qualomelhor.server;

import java.io.IOException;
import java.util.HashMap;
import javax.servlet.http.*; 


public class ChangeLocaleServlet extends HttpServlet { 

	private static final long serialVersionUID = 0;

	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { 
		String strLocale = (String)req.getAttribute("locale");
		System.out.println("changing locale.. :" + strLocale);

		HttpSession session = ((HttpServletRequest)req).getSession(true);
		HashMap<String, Object> mapSession = (HashMap<String, Object>)session.getAttribute("SESSIONVAR");
		mapSession.put("LOCALE", strLocale);
		session.setAttribute("SESSIONVAR", mapSession);
		session.setAttribute("LOCALE", strLocale);

		resp.sendRedirect("/");
	}

	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		doPost(req, resp);
	}
}